<template>
  <div class="block">
    <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage"
      :page-sizes="[2, 4, 6, 8]" :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper" :total="total">
    </el-pagination>
  </div>
</template>
<style></style>
<script>
export default {
  props: {
    total: {
      type: Number,
      default: 0
    },
    currentPage: {
      type: Number,
      default: 1
    },
    pageSize: {
      type: Number,
      default: 10
    }
  },
  methods: {
    handleSizeChange(val) {
      this.pageSize = val
      this.$emit('update:pageSize', val)
    },
    handleCurrentChange(val) {
      this.currentPage = val
      this.$emit('update:currentPage', val)
    }
  },
  watch: {
    total: {
      handler(newVal, oldVal) {
        this.total = newVal
      }
    },
    currentPage: {
      handler(newVal, oldVal) {
        this.currentPage = newVal
      }
    },
    pageSize: {
      handler(newVal, oldVal) {
        this.pageSize = newVal
        this.$emit('update:pageSize', newVal)

      }
    }
  }


}
</script>